package com.cy.sc.service;

import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;
import java.util.UUID;

@EnableBinding(Source.class) //Stream中对下层mq的绑定注解
public class MsgProviderImpl implements IMsgProvider{

    @Resource
    private MessageChannel output;//消息发送管道

    @Override
    public String send() {
        String str = UUID.randomUUID().toString();
        output.send(MessageBuilder.withPayload(str).build());
        System.out.println("消息发送");
        return str;
    }
}
